package com.roy.eureka.client.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;

//@Configuration
public class RibbonConfig {

	@Bean
	@LoadBalanced
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
	/*
	 * 配置ribbon 负载策略。
	 */
	@Bean
	public IRule ribbonRule() {
		//改为随机策略
		return new RandomRule();
		//默认的轮训策略
//		return new RoundRobinRule();
	}
}
